﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

namespace Web.manager
{
    public partial class LaiYuanFenXi : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                //接入类型:Web,Wap,IVR及手机客户端
                //接入日期:某一个日期
                //当天接入次数:

                //this.lb_ivr.Text = PhoneBook.Manage.Stat.getsiglemodel("ivr")["total"].ToString()+"次";
                //this.lb_mobile.Text = PhoneBook.Manage.Stat.getsiglemodel("mobile")["total"].ToString() + "次";
                //this.lb_wap.Text = PhoneBook.Manage.Stat.getsiglemodel("wap")["total"].ToString() + "次";
                //this.lb_web.Text = PhoneBook.Manage.Stat.getsiglemodel("web")["total"].ToString() + "次";
                this.txtStartTime.MyDateValue = DateTime.Now.AddDays(-1).ToString();
                this.txtEndTime.MyDateValue = DateTime.Now.AddDays(2).ToString();
                //自定义统计数据表
                QueryData();
            }

        }
        //导出
        protected void btn_export_Click(object sender, EventArgs e)
        {
            string filename = string.Format("Analysis{0}", Commons.StringUtil.GetID_15());
            Commons.FileUtil.GridExportExcel(GridView1, filename);
        }

        protected void btn_save_Click(object sender, EventArgs e)
        {
            DataTable dt = new DataTable();

            dt.Columns.Add("web");
            dt.Columns.Add("wap");
            dt.Columns.Add("ivr");
            dt.Columns.Add("mobile");

            dt.Rows.Add(PhoneBook.Manage.Stat.getsiglemodel("web", txtStartTime.MyDateValue, txtEndTime.MyDateValue)["total"].ToString() + "次",
                PhoneBook.Manage.Stat.getsiglemodel("wap", txtStartTime.MyDateValue, txtEndTime.MyDateValue)["total"].ToString() + "次",
                PhoneBook.Manage.Stat.getsiglemodel("ivr", txtStartTime.MyDateValue, txtEndTime.MyDateValue)["total"].ToString() + "次",
                PhoneBook.Manage.Stat.getsiglemodel("mobile", txtStartTime.MyDateValue, txtEndTime.MyDateValue)["total"].ToString() + "次");

            GridView1.DataSource = dt;
            GridView1.DataBind();
        }

        private void QueryData()
        {
            DataTable dt = new DataTable();

            dt.Columns.Add("web");
            dt.Columns.Add("wap");
            dt.Columns.Add("ivr");
            dt.Columns.Add("mobile");

            dt.Rows.Add(PhoneBook.Manage.Stat.getsiglemodel("web")["total"].ToString() + "次",
                PhoneBook.Manage.Stat.getsiglemodel("wap")["total"].ToString() + "次",
                PhoneBook.Manage.Stat.getsiglemodel("ivr")["total"].ToString() + "次",
                PhoneBook.Manage.Stat.getsiglemodel("mobile")["total"].ToString() + "次");

            GridView1.DataSource = dt;
            GridView1.DataBind();
        }
    }
}